
-- FirstLua={};
-- local this=FirstLua;--必须local，模仿CS的this

-- --目的：引入命名空间
-- --前提：把类在Tolua里面注册一下
-- local ParticleSystem = UnityEngine.ParticleSystem;
-- local GameObject = UnityEngine.GameObject;
-- local PrimitiveType = UnityEngine.PrimitiveType;
-- local Camera = UnityEngine.Camera;
-- local Physics = UnityEngine.Physics;
-- local Input = UnityEngine.Input;
-- local Text = UnityEngine.UI.Text;


-- this.score=0;

-- --整个lua逻辑的入口
-- function FirstLua.OnInitOK()
-- 	this.scoreText=GameObject.Find("Canvas/Text"):GetComponent(typeof(Text));
-- 	coroutine.start(FirstLua.CreateMouse)

-- 	coroutine.start(FirstLua.Update)
-- end

-- function FirstLua.CreateMouse()
-- 	while(true)do
-- 		coroutine.wait(1);
		
-- 		local go=GameObject.CreatePrimitive(PrimitiveType.Cube);
-- 		go.tag="Player";
-- 		go.transform.position=Vector3(math.random(-10,10),math.random(-10,10));
-- 		destroy(go,1);
-- 	end
-- end
-- function FirstLua.Update()
-- 	while(true) do
-- 		coroutine.step();

-- 		if(Input.GetMouseButtonDown(0))then
-- 			local ray = Camera.main:ScreenPointToRay(Input.mousePosition);
-- 	        local flag, hit = Physics.Raycast(ray, nil);
-- 	        if(flag)then
-- 	            if(hit.collider.gameObject.tag=="Player")then
-- 	            	this.score=this.score+1;
-- 	            	destroy(hit.collider.gameObject);
-- 	            	this.scoreText.text="score"..this.score;
-- 	            end
-- 	        end
-- 		end
-- 	end
-- end

-- function destroy(go,delay)
-- 	delay=delay or 0;--lua的默认值
-- 	GameObject.Destroy(go,delay);
-- end